//
//  AppDelegate.m
//  ScriptableDemo
//
//  Created by lg on 2020/5/26.
//  Copyright © 2020 lg. All rights reserved.
//

#import "AppDelegate.h"
#import <CoreGraphics/CoreGraphics.h>
#import "Person.h"

@interface AppDelegate ()

@property (weak) IBOutlet NSWindow *window;
@property (nonatomic,readonly) NSMutableArray<Person *> *personsArray;

@property (nonatomic) BOOL modified;

@end

@implementation AppDelegate {
//    NSMutableArray<Person *> *_persons;
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
//    NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
//    [appleEventManager setEventHandler:self andSelector:@selector(handleMoveMouseScriptCommand:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
    // Insert code here to initialize your application
    
    self.modified = YES;
    Person *p1 = Person.new;
    Person *p2 = Person.new;
    p1.name = @"Jack";
    p2.name = @"Rose";
//    _persons = [@[p1,p2] mutableCopy];
    _personsArray = [@[p1,p2] mutableCopy];
}


- (void)applicationWillTerminate:(NSNotification *)aNotification {
    // Insert code here to tear down your application
}

//- (NSArray *)personsArray {
//    return _persons;
//}
//- (void)removeObjectFromPersonsArrayAtIndex:(NSUInteger)index {
//    [_persons removeObjectAtIndex:index];
//}
//- (void)insertObject:(Person *)object inPersonsArrayAtIndex:(NSUInteger)index {
//    [_persons insertObject:object atIndex:index];
//}

//- (id)objectInPersonsArrayAtIndex:(NSUInteger)index {
//    NSLog(@"%s",__func__);
//    return _persons[index];
//}

- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key {
    NSLog(@"delegateHandlesKey %@", key);
    NSSet *keys = [NSSet setWithArray:@[
        @"personsArray",
        @"mouse",
        @"modified",
    ]];
    return [keys containsObject:key];
}

@end
